﻿@using Sausage.Web.Models
@using Sausage.Web.DataModel
@using Telerik.Web.Mvc.UI
@model DictionaryItemListRow
@{
    ViewBag.Title = "养护工程量填报";
    Layout = "~/Views/Shared/MainLayout.cshtml";

    //用于保存线路信息
    List<string> roadwayModels = new List<string>();

    //用于保存项目类型信息
    List<string> categoryModels = new List<string>();

    //查询项目类型信息
    using (SausageEntities entities = new SausageEntities())
    {
        //查询所有角色信息
        foreach (DictionayItem item in entities.DictionayItem.Where(item => item.DictionayID == 8).OrderBy(item => item.ItemName).ToArray())
        {
            //判断是否为空字符
            if (string.IsNullOrEmpty(item.ItemPinYin))
            {
                //转换为字符串
                roadwayModels.Add(string.Format(@"{{ Name: '{0}', PinYin: '{0}' }}", item.ItemName));
            }
            else
            {
                //转换为字符串
                roadwayModels.Add(string.Format(@"{{ Name: '{0}', PinYin: '{1} {0}' }}", item.ItemName, item.ItemPinYin));
            }
        }


        //查询所有养护类型信息
        foreach (MaintainCategory item in entities.MaintainCategory.Where(item => item.IsLeaf).OrderBy(item => item.CategoryPinYin).ToArray())
        {
            //转换为字符串
            categoryModels.Add(string.Format(@"{{ ID: '{0}', Name: '{1} {2}', Unit:'{3}' }}", item.CategoryID, item.CategoryPinYin, item.CategoryName, item.Unit));
        }
    }      
}
@section HeadCssLink
{
    <link href="@Url.Content("~/Content/Styles/ext-patch.css")" rel="stylesheet" type="text/css" />
}
@section HeadScriptLink
{
    <script src="@Url.Content("~/Scripts/ExtJS/locale/ext-lang-zh_CN.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/common.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/model.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/Sausage/MaintainQuantity/Submit.js")" type="text/javascript"></script>
    <script type="text/javascript">
        //用于保存线路信息
        var master_roadway =
        [
            @Html.Raw(System.String.Join(",", roadwayModels))
        ];

        //用于保存计量单位存储
        var store_master_roadway = null;

        //用于保存类型信息
        var master_category =
        [
            @Html.Raw(System.String.Join(",", categoryModels))
        ];

        //用于保存计量单位存储
        var store_master_category = null;
    </script>
}
<h2>
    @ViewBag.Title
</h2>
<br />
<div id="data-grid" class="div-grid-box">
</div>
